package com.yto.hrreport.event.buttons {
	
	import com.yto.hrreport.command.sysTemplatePanel;
	import com.yto.hrreport.event.buttons.superbutton.ButtonEvent;
	
	import mx.containers.Canvas;
	import mx.containers.HDividedBox;
	import mx.controls.Tree;
	
	public class TempAddButtonEvent extends ButtonEvent {
		
		private static var addEvent : TempAddButtonEvent = new TempAddButtonEvent();
		private static var parentName : String;
		
		public function TempAddButtonEvent() {
			super();
		}
		
		public static function getInstance(parentName : String) : TempAddButtonEvent {
			TempAddButtonEvent.parentName = parentName;
			return addEvent;
		}
		
		public function addEvent() : void {
			
			var parentCanvas : Canvas = Canvas(hrreport.ui.mainNavigator.getChildByName(parentName + "_canvas"));
			var headCanvas : Canvas = Canvas(parentCanvas.getChildByName(parentName + "_headCanvas"));
			var bodyCanvas : Canvas = Canvas(parentCanvas.getChildByName(parentName + "_bodyCanvas"));
			var hdivBox : HDividedBox = HDividedBox(bodyCanvas.getChildByName(parentName + "_hdivBox"));
			var sysTree : Tree = Tree(hdivBox.getChildByName(parentName + "_sysTree"));
			var template : sysTemplatePanel = sysTemplatePanel.getInstance();
			
			sysTree.enabled = false;
			
			template.txtFieldCode.enabled = true;
			template.txtFieldName.enabled = true;
			template.combPos.enabled = true;
			
			template.btnAddRow.enabled = true;
			template.btnEditGrid.enabled = true;
			
			updateButtons(null , "tempAdd" , headCanvas , true);
			
		}
	}
}